import csv
from words import value

def solution():
    filename="names.txt"
    
    file = open(filename, "r")
    reader = csv.reader(file)    
    names = sorted(reader.next())
    
    total = 0
    pos = 0
    
    for name in names:
        pos += 1
        total += value(name) * pos
            
    print total

from timeit import Timer
print Timer('solution()', 'from __main__ import solution').timeit(1)